<?php
namespace app\validate;
use share\validate\SceneValidate;

class OssProductValidate extends SceneValidate{

    /**
     * 通用规则
     */
    protected $rule = [
        'id' => 'require|integer',
        'content' => 'require|length:1,1200',
        'name' => 'require|length:1,200',
        'open_app_id' => 'require|integer|min:1',
        'products' => 'require|array',
        'sku' => 'length:2,60',
        'aliyun_cloud_storage_id' => 'require|integer|min:1',
        'sn' => 'require|alphaNum|length:2,64',
        'price' => 'require|integer|min:1',
        'state' => 'require|integer|min:1',
        'type' => 'require|integer|min:1|max:3',
        'num' => 'require|integer|min:1',
        'user_id' => 'require|length:2,64',
    ];    

    /**
     * 自定义场景的规则
     */
    protected $sceneRules = [
        'set' =>[
            'id' => 'require|integer',
            'account' => 'length:2,16',
            'vendor' => 'length:2,20',
        ],
    ];

    protected $scene = [
        'list' => ['level','account','vendor'],
        'set' => ['id','account','vendor'],
        'del'  => ['id'],
        'assign' => ['open_app_id','products'],
        'assign_item' => ['id','aliyun_cloud_storage_id','sku','name','content','price','state','type','num'],
        'getFree' => ['sn','sku','user_id'],
    ];
}
